Fix ransack_alias issue, close #1239 - #1512
Conversation
5cc98a5 to
a0af78f
Compare
|
Can #1525 also fix this issue? Because now |
|
@itsalongstory thanks for check |
diff --git a/lib/ransack/nodes/grouping.rb b/lib/ransack/nodes/grouping.rb
index 95d6488..6d72097 100644
--- a/lib/ransack/nodes/grouping.rb
+++ b/lib/ransack/nodes/grouping.rb
@@ -53,7 +53,7 @@ module Ransack
end
def []=(key, value)
- conditions.reject! { |c| c.same_name_or_key?(key) }
+ conditions.reject! { |c| c.same_name_or_key?(key) && c.value == value.value }
self.conditions << value
endMaybe we need to |
|
ok, got a problem. Maybe this commit will be enough - aa2062c |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue with ransack_alias where conditions with the same aliased attribute name but different values were incorrectly being overwritten instead of being combined as separate conditions.
- Modifies the condition rejection logic to preserve conditions with different values
- Ensures that aliased attributes with different values generate multiple WHERE clauses
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
scarroll32
left a comment
There was a problem hiding this comment.
@copilot can you please add test cases to handle the various nil cases to ensure the reject! is working in all cases?
conditions.reject! { |c| c.key == key.to_s && c&.value == value&.value }
Close #1239
test_ransack.rb